/*
 * =====================================================================================
 *
 *       Filename:  webNavi_1028.cc
 *
 *    Description:  use stack to simulate the web navigation
 *
 *        Version:  1.0
 *
 *        Created:  09/20/2012 12:17:06 AM
 * =====================================================================================
 */
#include	<iostream>
#include	<stack>
#include	<string>

using namespace std;

string currpage;
stack<string> backStack;
stack<string> forwardStack;

int main(int argc, char *argv[])
{
    string cmd;
    currpage = "http://www.acm.org/";
    while (cin >> cmd)
    {
        if (cmd == "QUIT")
            break;
        if (cmd == "VISIT") {
            string newpageurl;
            cin >> newpageurl;
            backStack.push(currpage);
            currpage = newpageurl;
            while (!forwardStack.empty())
                forwardStack.pop();
        } else if (cmd == "BACK") {
            if (backStack.empty()) {
                cout << "Ignored\n";
                continue;
            } else {
                forwardStack.push(currpage);
                currpage = backStack.top();
                backStack.pop();
            }
        } else if (cmd == "FORWARD") {
            if (forwardStack.empty()) {
                cout << "Ignored\n";
                continue;
            } else {
                backStack.push(currpage);
                currpage = forwardStack.top();
                forwardStack.pop();
            }
        }
        cout << currpage << std::endl;
    }
}

